package com.disapand.mybaby.handle;

import lombok.Getter;
import lombok.ToString;

/**
 * @author disapand
 */
@Getter
@ToString
public class ResultVO<T> {
    /**
     * 定义状态码
     */
    private final Integer code;

    /**
     * 响应信息，用来说明响应的情况
     */
    private String msg;

    /**
     * 响应的具体数据
     */
    private T data;

    public ResultVO(T data) {
        this(ResultCode.SUCCESS, data);
    }

    public ResultVO(ResultCode resultCode, T data) {
        this.code = resultCode.getCode();
        this.msg = resultCode.getMsg();
        this.data = data;
    }

    public static ResultVO<String> ofSuccess () {
        return new ResultVO<>(null);
    }

    public static ResultVO<String> ofSuccess (String data) {
        return new ResultVO<>(data);
    }
}
